import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA } from '@/config'

export async function login(data) {
  if (loginRSA) {
    data = await encryptedData(data)
  }
  return request({
    url: '/admin.php?s=Admin.Basic_User.LoginByPassword',
    method: 'post',
    data,
  })
}

export async function socialLogin(data) {
  if (loginRSA) {
    data = await encryptedData(data)
  }
  return request({
    url: '/socialLogin',
    method: 'post',
    data,
  })
}

export function getUserId(data) {
  return request({
    url: '/admin.php?s=Admin.Basic_User.GetMyTeamUserID',
    method: 'post',
    data,
  })
}

export function getUserInfo(data) {
  return request({
    url: '/admin.php?s=Admin.Basic_User.UserDetail',
    method: 'post',
    data,
  })
}

export function getInfo(data) {
  return request({
    url: '/admin.php?s=Admin.Basic_User.GetUserInfo',
    method: 'post',
    data,
  })
}

export function updateInfo(data) {
  return request({
    url: '/admin.php?s=Admin.Basic_User.UpdateUserInfo',
    method: 'post',
    data,
  })
}

export function register(data) {
  return request({
    url: '/admin.php?s=Admin.Basic_User.RegisterByPassword',
    method: 'post',
    data,
  })
}

export function captcha() {
  return request({
    url: '/?s=App.Common_Tools.CreateCaptcha',
    method: 'post',
    data: {
      size_width: 120,
      size_height: 48,
    }
  })
}

export function findpwd(data) {
  return request({
    url: '/admin.php?s=Admin.Basic_User.ResetPasswordByMobile',
    method: 'post',
    data
  })
}

export function smsCode(data) {
  return request({
    url: '/?s=App.Common_Sms.SendSmsCaptcha',
    method: 'post',
    data
  })
}